using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ShotGun : Gun
{
    public int bulletNum;
    public float bulletAngle;

    protected override void fire()
    {
        player.GetComponent<PlayerCon>().parameterPlayer.NowMP -= MP_cost;
        anim.SetTrigger("shoot");
        float median = (bulletNum + 1) / 2;
        for (int i = 1; i <= bulletNum; i++) 
        {
            GameObject bullet = ObjectPool.Instance.GetObject(bulletPrefab);
            bullet.transform.position = muzzlePos.position;
            float angel = Random.Range(-angle / 2, angle / 2);
            Vector2 _direction = Quaternion.AngleAxis(angel + bulletAngle * (i - median), Vector3.forward) * direction;
            bullet.transform.right = _direction;
            bullet.GetComponent<bullet>().SetSpeed(_direction);
        }
    }
}
